import 'package:cook_dinner/config/include.dart';
import 'package:flutter/material.dart';

class CartItem extends StatefulWidget {
  const CartItem({Key? key, this.title}) : super(key: key);
  final String? title;

  @override
  State<CartItem> createState() => _CartItemState();
}

class _CartItemState extends State<CartItem> {
  bool _current = false;

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.only(bottom: 34.rpx),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          InkWell(
            onTap: () {
              setState(() {
                _current = !_current;
              });
            },
            child: Container(
              width: 22.rpx,
              height: 22.rpx,
              margin: EdgeInsets.only(right: 18.rpx),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(11.rpx),
                color: _current ? const Color(0xffFA8303) : Colors.transparent,
                border: Border.all(
                    color: _current
                        ? const Color(0xffFA8303)
                        : const Color(0xff8f8f8f),
                    width: 1.rpx),
              ),
            ),
          ),
          Expanded(
            child: Container(
              height: 98.rpx,
              padding: EdgeInsets.only(
                left: 8.rpx,
                top: 7.rpx,
                bottom: 7.rpx,
              ),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(20.rpx),
              ),
              child: Row(
                children: [
                  ClipRRect(
                    borderRadius: BorderRadius.circular(20.rpx),
                    child: Image.asset(
                      'assets/images/prot01.png',
                      width: 84.rpx,
                      height: 84.rpx,
                      fit: BoxFit.cover,
                    ),
                  ),
                  SizedBox(width: 15.rpx),
                  Expanded(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: [
                        Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            SizedBox(height: 8.rpx),
                            Text(
                              widget.title ?? '',
                              style: TextStyle(
                                fontSize: 14.rpx,
                                color: const Color(0xff1a1a1a),
                              ),
                            ),
                            SizedBox(height: 8.rpx),
                            Text(
                              '重量：2kg',
                              style: TextStyle(
                                fontSize: 14.rpx,
                                color: const Color(0xffcccccc),
                              ),
                            ),
                            SizedBox(height: 8.rpx),
                            Text(
                              '¥50',
                              style: TextStyle(
                                fontSize: 14.rpx,
                                color: const Color(0xff1a1a1a),
                              ),
                            ),
                          ],
                        ),
                        Padding(
                          padding: EdgeInsets.only(bottom: 8.rpx),
                          child: Row(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              InkWell(
                                child: Container(
                                  width: 16.rpx,
                                  height: 16.rpx,
                                  alignment: Alignment.center,
                                  decoration: BoxDecoration(
                                    color: const Color(0xffFA8303),
                                    borderRadius: BorderRadius.circular(2.rpx),
                                  ),
                                  child: Icon(
                                    Icons.remove,
                                    size: 10.rpx,
                                    color: Colors.black,
                                  ),
                                ),
                              ),
                              SizedBox(
                                width: 24.rpx,
                                height: 16.rpx,
                                child: Center(
                                  child: Text(
                                    '0',
                                    style: TextStyle(
                                        fontSize: 14.rpx, color: Colors.black),
                                  ),
                                ),
                              ),
                              InkWell(
                                child: Container(
                                  width: 16.rpx,
                                  height: 16.rpx,
                                  alignment: Alignment.center,
                                  decoration: BoxDecoration(
                                    color: const Color(0xffFA8303),
                                    borderRadius: BorderRadius.circular(2.rpx),
                                  ),
                                  child: Icon(
                                    Icons.add,
                                    size: 10.rpx,
                                    color: Colors.black,
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                  SizedBox(width: 18.rpx),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
